<template>
	<view>
		<u-navbar :is-back="false"></u-navbar>
		<!-- 测试 -->
		<!-- <button type="default" @click="test">测试</button> -->
		<!-- 内容 -->
		<lg-tabs-swiper type="issue" :swipterList="[{ name: '最近学习'}, { name: '正在审批' }, { name: '我的收藏' }]">
			<template v-slot:tab-0="{data}">
				<view class="px-6 py-6">
					<u-time-line>
						<u-time-line-item nodeTop="2" v-for=" (line,index) in data" :key='index'>
							<template v-slot:node>
								<view>
									<u-row>
										<u-col span="12" justify="center" align="center">
											<h1>{{trimTime(line.visit_time)[0]}}</h1>
										</u-col>
									</u-row>
									<u-row>
										<u-col span="12" justify="center" align="center" >
											{{trimTime(line.visit_time)[1]}}
										</u-col>
									</u-row>
								</view>
							</template>
							<template v-slot:content>
								<view style="background-color: #FFFFFF;">
									<u-row customStyle="margin-bottom: 10px">
										<u-col span="4">
											<view class="cover-img">
												<u-image :showLoading="true" :src="line.activity_cover" width="80px"
													height="80px" ></u-image>
											</view>
										</u-col>
										
										<u-col span="6" align="center">
											<view class="">
											  <h1>{{line.activity_name}}</h1>	
											</view>
											<u-row>
												<u-col span="6">
												  已完成	{{line.progress_score}}
												</u-col>
												<u-col span="6">
												 	用时{{line.total_visit_duration}}
												</u-col>
											</u-row>
											<u-row>
												<u-col span="6">
												 	课程:{{line.course_count}}
												</u-col>
												<u-col span="6">
													考试:{{line.exam_count}}
												</u-col>
											</u-row>
										</u-col>
										<u-col span="2">
										</u-col>
									</u-row>

								</view>
							</template>
						</u-time-line-item>
					</u-time-line>
				</view>
			</template>
		</lg-tabs-swiper>
		<!-- 提示 -->
		<u-toast ref="uToast" />
		<!-- 底部导航栏 -->
		<u-tabbar :list="tabbar"></u-tabbar>
	</view>
</template>

<script>
	import {
		TUser
	} from '../../entity/index.js';
	import {
		login,
		queryLoginInfo,
		updateUser,
		queryPersonalInfo,
		queryMyActivityPage
	} from '../../services/index.js';
	export default {
		data() {
			return {
				tabbar: '',
				parentMethods: queryMyActivityPage,
				parent_requests: [{
						requester: async (prams = 1) => {
							const {
								success,
								data: {
									data: {
										rows: data = []
									}
								} = {}
							} = await queryMyActivityPage({
								page: prams,
								pageSize: 10,
								activity_type: 'CLASS',
								query_way: 'recently_learn'
							});
							return data;
						},
						type: 'paging',
						page: 0
					},
					{
						requester: async (prams = 1) => {
							const {
								success,
								data: {
									data: {
										rows: data = []
									}
								} = {}
							} = await queryMyActivityPage({
								page: prams,
								pageSize: 10,
								activity_type: 'CLASS',
								query_way: 'approving'
							});
							return data;
						},
						type: 'paging',
						page: 0
					},
					{
						requester: async (prams = 1) => {
							const {
								success,
								data: {
									data: {
										rows: data = []
									}
								} = {}
							} = await queryMyActivityPage({
								page: prams,
								pageSize: 10,
								activity_type: 'CLASS',
								query_way: 'my_collect'
							});
							return data;
						},
						type: 'paging',
						page: 0
					}
				]
			};
		},
		onShow() {
			this.tabbar = getApp().globalData.tabbar;
		},
		methods: {
			trimTime(time = ''){
				 const times = time.split('-')
				 if(times.length > 1){
					 return [times[0],`${times[1]}月${times[2]}日`]
				 }
				 return ['--','--']
			},
			async test() {
				console.log(LgRender);
				//   const encryptPwd = this.$utils.encrypt('tea##666')
				// // console.log( await  login({loginId:'canlong.shen',password:encryptPwd}));
				// const user = new TUser()
				// const {success,data:{data}} =  await  queryPersonalInfo()
				// user.fill(data)
				// user.sex = user.sex_id == '009' ? '男' : '女'
				// console.log(user);
				//    await updateUser({
				// 	data:{
				// 		user_tcl:user
				// 	},
				// 	where:{
				// 		username:'canlong.shen'
				// 	}
				// })
				// console.log(await queryMyActivityPage());
			}
		}
	};
</script>

<style lang="scss" scoped>
	.cover-img{
		border-radius: 100rpx;
	}
</style>
